package com.example.javabasic.thread.classtwo.activeobject.demo1;

/**
 * activeObject 的代理类
 */
class ActiveObjectsProxy implements ActiveObjects {

    private final SchedulerThread schedulerThread;
    private final Servant servant;

    public ActiveObjectsProxy(SchedulerThread schedulerThread, Servant servant) {
        this.schedulerThread = schedulerThread;
        this.servant = servant;
    }

    @Override
    public Result makeString(int count, char fillChar) {
        FutureResult futureResult  = new FutureResult();
        schedulerThread.invoke(new MakeStringRequest(servant,futureResult,count,fillChar));
        return futureResult;
    }

    @Override
    public void displayString(String text) {
        schedulerThread.invoke(new DisplayStringRequest(servant,text));
    }
}
